home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: tanmoy@qcd.Lanl.GOV (Tanmoy Bhattacharya)
- Newsgroups: comp.std.c,comp.lang.c.moderated
- Subject: Re: Integral promotion.
- Date: 17 Feb 1996 11:53:29 -0600
- Organization: Los Alamos National Laboratory
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4g54mp$agm@solutions.solon.com>
- References: <4fstj7$2l6@solutions.solon.com> <4fu835$9de@solutions.solon.com>
- <4fvgrm$dv9@solutions.solon.com> <4g28hr$qko@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4g28hr$qko@solutions.solon.com> thads@csn.net (Thad Smith)
- writes:
- <snip>
- In article <4fvgrm$dv9@solutions.solon.com>, msb@sq.com wrote:
- >Oh dear, I have to correct Chris Torek (torek@bsdi.com).
-
- >Thus even in ANSI C, if this function is called this way:
- >
- > extern short p, q, r, test(short,short);
- > r = test(p,q);
- >
- >the values from p and q are still converted from short to int and back
- >to short.
-
- I find nothing in the Standard that states that the arguments undergo
- integral promotions before being assigned to the function parameters.
-
- The way I read the standard (6.2.1.1):
-
- ``A char, a short int, or an int bit-field, or their signed or unsigned
- varieties, or an enumeration type, may be used in an expression
- wherever an int or unsigned int may be used. ...< describing integral
- promotions >... these are called integral promotions.''
-
- Seems to imply that whenever a value of type `int' is a possibility,
- integral promotions always take place. Without enum types, I don't see
- how this matters in a function call, as long as implementation defined
- behaviour is reasonable (i.e. signed char->int->short is same as
- signed char->short etc.)
-
- For enums, I am confused. If an enum type is compatible with `long',
- does integral _promotion_ narrow it to an int or unsigned int :-)?
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-